import Vue from 'vue';
import Dialog from './dialog.vue';
const DialogCtor = Vue.extend(Dialog);

const exportFieldDialog = (options) => {
    console.log(options);
    return new Promise((resolve, reject) => {
        const instance = new DialogCtor({
            el: document.createElement('div')
        });
        document.body.appendChild(instance.$el);
        console.log(instance);
        Vue.nextTick(() => {
            instance.dialogVisible = true;
        });

        // const sure = instance.sure;
        instance.sure = () => {
            console.log('点击确定');
            resolve('点击了确定');
        };
        instance.close = () => {
            console.log('点击关闭');
            reject('点击了关闭');
            instance.dialogVisible = false;
            document.body.removeChild(instance.$el);
            instance.$destroy();
        };
    });
};

export default exportFieldDialog;
